<%@page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>


<script type="text/javascript">
	var form_url = $.webapp.root+"/admin/oa/yhyl/add.do" ;
	var currentYear = $.date.format(new Date(), "yyyy");
	var tabsContainer, org, position, $person_select_dg ;
	$(function() {
		if($('input[name=id]').val().length > 0) {
			loadData($('input[name=id]').val()) ;
		}  else {
			selectField() ;
		}
	});
	
	function loadData(id) {
		selectField() ;
		
		form_url = $.webapp.root+"/admin/oa/yhyl/update.do" ;
		$.post($.webapp.root+"/admin/oa/yhyl/get.do", {id: id, year: "${year}"}, function(result) {
			if (result.id != undefined) {
				$('#basic_info_form').form('load', result);
			}
		}, 'json').error(function() { $.easyui.loaded(); });
		
	}
	
	function selectField() {
		org = $("#org").combotree({
			url : $.webapp.root+"/static_res/org.tree.json", value: '${USER_SESSION.user.org_id}',
			idFiled:'pid', textFiled:'name', editable: false, required:true, lines:true, autoShowPanel: false,
			onSelect: function(record) {
				$("input[name=projDeptName]").val(record.name) ;
			}
		});
		
		var data = {"dictCode": "YHYL_AJLB,YHYL_SZZT,YHYL_HTPSZK"} ;
		$.post($.webapp.root+"/admin/system/dict/doNotNeedSession_dictAttrMaps.do", data, function(result) {
			$("#YHYL_AJLB").combobox({
				editable: false, required:false,
				valueField: 'text', textField: 'text', panelHeight: 'auto', data: result.YHYL_AJLB
			}) ;
			$("#YHYL_SZZT").combobox({
				editable: false, required:false,
				valueField: 'text', textField: 'text', panelHeight: 'auto', data: result.YHYL_SZZT
			}) ;
			/* $("#YHYL_KX").combobox({
				editable: false, required:false,
				valueField: 'text', textField: 'text', panelHeight: 'auto', data: result.YHYL_KX
			}) ; */
			$("#YHYL_HTPSZK").combobox({
				editable: false, required:false,
				valueField: 'text', textField: 'text', panelHeight: 'auto', data: result.YHYL_HTPSZK
			}) ;
		}, 'json');
	}
	
	//提交表单数据
	var submitNow = function($d, $dg, flag) {
		var bform = $.webapp.serializeObject("#basic_info_form") ;
		var o = {} ;
		addAttr(o, bform) ;
		
		$.post(form_url, o, function(result) { 
			if (result.status) {
				$dg.datagrid('reload');alertify.success(result.msg);$.easyui.loaded();
				if(flag==undefined||flag==false){$d.dialog("close") ;}
			} else {
				$.easyui.loaded();$.messager.alert("错误", result.msg, "error");
			}
		}, 'json').error(function() { $.easyui.loaded(); });
	};
	
	//验证表单
	var submitForm = function($d, $dg, flag) { 
		if($('#basic_info_form').form('validate')) {
			$.easyui.loading({ msg: "数据提交中，请稍等..." });
			submitNow($d, $dg, flag) ;
		}
	};
	//添加数据
	function addAttr(datas, obj){
		$.each(obj, function(p, v){
			datas[p] = v ;
		}) ;
	}
	
	
</script>
<form id="basic_info_form">
	<div class="form_container">
		<input type="hidden" name="id" value="${id}" />
		<table class="tableform">
			<tr>
				<th>引合ID：</th>
				<td><input name="yhId" class="easyui-validatebox" data-options="required:true" type="text" /></td>
				<th>项目ID ：</th>
				<td><input name="projectId" class="easyui-validatebox" data-options="required:false" type="text" /></td>
			</tr>
			<tr>
				<th>案件名称：</th>
				<td colspan="3"><input name="ajmc" class="easyui-validatebox" data-options="required:true" type="text" style="width:584px;" /></td>
			</tr>
			<tr>
				<th>案件種別：</th>
				<td>
					<input id="YHYL_AJLB" name="ajzl" type="text" class="easyui-combobox" style="width:219px;height:25px;"/>
				</td>
				<th>客先：</th>
				<td>
					<input name="client" type="text" class="easyui-validatebox" />
				</td>
			</tr>
			<tr>
				<th>受注状態：</th>
				<td>
					<input id="YHYL_SZZT" name="szzk" type="text" class="easyui-combobox" style="width:219px;height:25px;"/>
				</td>
				<th>合同評審状況：</th>
				<td>
					<input id="YHYL_HTPSZK" name="htpszk" type="text" class="easyui-combobox" style="width:219px;height:25px;"/>
				</td>
			</tr>
			<tr>
				<th>開始予定：</th>
				<td>
					<input type="text" name="ksyd" onClick="WdatePicker()" style="width:215px;height:22px;"/>
					<!-- <input name="ksyd" style="width:219px;height:25px;" class="easyui-my97" data-options="isShowClear:true" /> -->
				</td>
				<th>終了予定：</th>
				<td>
					<input type="text" name="jsyd" onClick="WdatePicker()" style="width:215px;height:22px;"/>
					<!-- <input name="jsyd" style="width:219px;height:25px;" class="easyui-my97" data-options="isShowClear:true" /> -->
				</td>
			</tr>
			<tr>
				<th>提案者：</th>
				<td>
					<input name="taz" type="text" class="easyui-validatebox"/>
				</td>
				<th>責任部門：</th>
				<td>
					<input id="org" name="zrbmId" style="width:219px;height:25px;" />
				</td>
			</tr>
			<tr>
				<th>部長：</th>
				<td>
					<input name="bz" type="text" class="easyui-validatebox"/>
				</td>
				<th>项目系数：</th>
				<td>
					<input name="xmxsKz" type="text" class="easyui-validatebox" />
				</td>
			</tr>
			<tr>
			<th>备注：</th>
			<td colspan="3"> 
				<textarea name="remark" style="width:591px;height:70px;max-width:591px;min-width:217px;max-height:70px;min-height:70px;"></textarea>
			</td>
		</tr>
		</table>
	</form>
	
